In Es6 you can create a class using the Class keyword.Below is sample javascript class in ES6.
class User{
constructor(name,age) {
this.name = name;
this.age = age;
}
getData() {
console.log(this.name + " is " + this.age + " years old !");
}
}
var user = new User("foo", 7);
s1.getData();
Posted Date:- 2021-10-08 09:57:52
what is meant by Class Expressions?
What is difference between CoffeeScript and es6 ?
What is difference between ES6 and typescript?
What is Prototypal Inheritance in Javascript?
What is the use of let & const in JavaScript?
How to create a Javascript class in ES6?
Explain Destructuring Assignment in ES6?
What are the classes and proxies?
What is spread, default and rest parameter?
Explain the reason for using ES6 classes.
Explain the motivation behind Symbols to ES6.
Explain Internationalization and Localization.